
package com.kingdee.eas.custom.aoyuan.aytime.bizbill.web;

import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.operamasks.faces.annotation.Inject;
import org.operamasks.faces.annotation.ManagedBean;
import org.operamasks.faces.annotation.ManagedBeanScope;
import com.kingdee.bos.metadata.IMetaDataPK;
import com.kingdee.bos.metadata.MetaDataPK;
import com.kingdee.bos.metadata.entity.SelectorItemCollection;
import com.kingdee.bos.waf.annotation.IBOSBizCtrl;
import com.kingdee.bos.waf.util.OperateState;
import com.kingdee.bos.waf.winlet.edit.EditBean;
import com.kingdee.eas.framework.CoreBaseInfo;
import com.kingdee.eas.framework.ICoreBase;
import org.operamasks.faces.annotation.Accessible;
import org.operamasks.faces.component.form.impl.*;
import com.kingdee.bos.waf.action.AbstractWebAction;
import javax.faces.event.AbortProcessingException;
import javax.faces.context.FacesContext;
import org.operamasks.faces.component.action.ActionEvent;
import org.operamasks.faces.annotation.Action;
import com.kingdee.bos.waf.winlet.BaseBean;
import com.kingdee.bos.metadata.entity.SelectorItemInfo;

import com.kingdee.eas.custom.aoyuan.aytime.bizbill.IHolidayBill;
import com.kingdee.eas.custom.aoyuan.aytime.bizbill.HolidayBillInfo;
import com.kingdee.eas.custom.aoyuan.aytime.bizbill.HolidayBillEntryInfo;
import com.kingdee.eas.custom.aoyuan.aytime.bizbill.HolidayBillEntryCollection;

public abstract class AbstractHolidayBillEditUIBean extends com.kingdee.bos.waf.winlet.edit.EditBean {

	@IBOSBizCtrl
	protected com.kingdee.eas.custom.aoyuan.aytime.bizbill.IHolidayBill service;
	@Accessible
	protected ActionAuditPass actionAuditPass = null;
	@Accessible
	protected ActionAuditFail actionAuditFail = null;
	@Accessible
	protected ActionCloseBill actionCloseBill = null;

	@Inject("custom.aoyuan.aytime.bizbill.HolidayBillEntryBean")
	protected HolidayBillEntryBean holidayBillEntryBean;
	public AbstractHolidayBillEditUIBean() {
		super();
        // actionAuditPass
        this.actionAuditPass = (ActionAuditPass)com.kingdee.bos.waf.action.WebActionFactory
				.createWebAction("actionAuditPass", ActionAuditPass.class,getServiceContext());
		this.actionAuditPass.setBaseBean(this);
        // actionAuditFail
        this.actionAuditFail = (ActionAuditFail)com.kingdee.bos.waf.action.WebActionFactory
				.createWebAction("actionAuditFail", ActionAuditFail.class,getServiceContext());
		this.actionAuditFail.setBaseBean(this);
        // actionCloseBill
        this.actionCloseBill = (ActionCloseBill)com.kingdee.bos.waf.action.WebActionFactory
				.createWebAction("actionCloseBill", ActionCloseBill.class,getServiceContext());
		this.actionCloseBill.setBaseBean(this);
	}

	
	
	@Override
	public void createNewModel() {
		model = new HolidayBillInfo();
	}

	@Override
	public void pageOnload() {
		super.pageOnload();
		
		HolidayBillEntryCollection entryCol_0 = ((HolidayBillInfo) model).getEntrys();

		List<CoreBaseInfo> listModel_0 = new LinkedList<CoreBaseInfo>();
		if (entryCol_0 != null)
		{
			for (int i = 0, n = entryCol_0.size(); i < n; i++) {
				listModel_0.add(entryCol_0.get(i));
			}
	
			holidayBillEntryBean.setListModel(listModel_0);
		}

		
	}

	@Override
	public void saveModel() {
		updateModel();
		super.saveModel();
	}

	@Override
	public void submitModel() {
		updateModel();
		super.submitModel();
	}


	protected void updateModel() {
		
		if (holidayBillEntryBean == null)
			holidayBillEntryBean = (HolidayBillEntryBean) com.kingdee.bos.waf.util.BeanUtil
					.getBean("custom.aoyuan.aytime.bizbill.HolidayBillEntryBean");

		holidayBillEntryBean.updataModel();
		List<CoreBaseInfo> entryModel_0 = holidayBillEntryBean.getListModel();
		((HolidayBillInfo) model).getEntrys().clear();
		if (entryModel_0 != null) {
			for (CoreBaseInfo entryInfo : entryModel_0) {
				((HolidayBillInfo) model).getEntrys().add(
						(HolidayBillEntryInfo) entryInfo);
			}
		}

	}
	
	
	//entry
	public void holidayBillEntryBean_apendRow(){
		holidayBillEntryBean.appendRow();
	}
	public void holidayBillEntryBean_removeRow(){
		holidayBillEntryBean.removeRow();
	}
		

	@Override
	protected ICoreBase getBizInterface() {
		return service;
	}
	
	@Override
	public IMetaDataPK getMetaDataPK() {
		return new MetaDataPK("com.kingdee.eas.custom.aoyuan.aytime.bizbill.web.HolidayBillEditUI");
	}
	
	@Override
	protected String getEntryPKName() {
	
		return "entrys.id";
	
	}

	@Override
	public SelectorItemCollection getSelectors() {
		SelectorItemCollection sic = super.getSelectors();
        sic.add(new SelectorItemInfo("number"));
        sic.add(new SelectorItemInfo("bizDate"));
        sic.add(new SelectorItemInfo("handler.*"));
        sic.add(new SelectorItemInfo("description"));
        sic.add(new SelectorItemInfo("auditor.*"));
        sic.add(new SelectorItemInfo("entrys.id"));
        sic.add(new SelectorItemInfo("entrys.BizDate"));
        sic.add(new SelectorItemInfo("entrys.holidayType.*"));
        sic.add(new SelectorItemInfo("entrys.StartTime"));
        sic.add(new SelectorItemInfo("entrys.EndTime"));
        sic.add(new SelectorItemInfo("entrys.Remark"));
        sic.add(new SelectorItemInfo("entrys.totalhour"));
        sic.add(new SelectorItemInfo("Dept.*"));
        sic.add(new SelectorItemInfo("position.*"));
        sic.add(new SelectorItemInfo("applier.*"));
        sic.add(new SelectorItemInfo("Startdate"));
        sic.add(new SelectorItemInfo("endDate"));
        sic.add(new SelectorItemInfo("status"));
        sic.add(new SelectorItemInfo("Remark"));
        sic.add(new SelectorItemInfo("auditDate"));
	
		return sic;
	}	
	protected void actionAuditPass_actionPerformed(ActionEvent event) throws AbortProcessingException {
	}
	protected void actionAuditFail_actionPerformed(ActionEvent event) throws AbortProcessingException {
	}
	protected void actionCloseBill_actionPerformed(ActionEvent event) throws AbortProcessingException {
	}	
	public static class ActionAuditPass extends AbstractWebAction {
		private BaseBean baseBean;

		public BaseBean getBaseBean() {
			return baseBean;
		}
	
		public void setBaseBean(BaseBean baseBean) {
			this.baseBean = baseBean;
		}
		@Override
		public void processAction(ActionEvent event) throws AbortProcessingException {
			try {
				((AbstractHolidayBillEditUIBean)baseBean).actionAuditPass_actionPerformed(event);
			} catch (Exception e) {
				e.printStackTrace();
				throw new AbortProcessingException(e);
			}
		}
	}
	public static class ActionAuditFail extends AbstractWebAction {
		private BaseBean baseBean;

		public BaseBean getBaseBean() {
			return baseBean;
		}
	
		public void setBaseBean(BaseBean baseBean) {
			this.baseBean = baseBean;
		}
		@Override
		public void processAction(ActionEvent event) throws AbortProcessingException {
			try {
				((AbstractHolidayBillEditUIBean)baseBean).actionAuditFail_actionPerformed(event);
			} catch (Exception e) {
				e.printStackTrace();
				throw new AbortProcessingException(e);
			}
		}
	}
	public static class ActionCloseBill extends AbstractWebAction {
		private BaseBean baseBean;

		public BaseBean getBaseBean() {
			return baseBean;
		}
	
		public void setBaseBean(BaseBean baseBean) {
			this.baseBean = baseBean;
		}
		@Override
		public void processAction(ActionEvent event) throws AbortProcessingException {
			try {
				((AbstractHolidayBillEditUIBean)baseBean).actionCloseBill_actionPerformed(event);
			} catch (Exception e) {
				e.printStackTrace();
				throw new AbortProcessingException(e);
			}
		}
	}	
    	protected String getTDTemplateName() {
	    	return "/bim/custom/aoyuan/aytime/bizbill/HolidayBill";
		}
	    protected com.kingdee.bos.metadata.IMetaDataPK getTDQueryPK() {
	    	return new com.kingdee.bos.metadata.MetaDataPK("com.kingdee.eas.custom.aoyuan.aytime.bizbill.app.HolidayBillQuery");
	    }

}
